using System;

namespace foundation
{
    public class EndianTransform
    {
        public static byte[] transform(byte[] bytes, bool littleEndian, bool clone = false)
        {
            if (clone)
            {
                bytes = (byte[]) bytes.Clone();
            }

            if (littleEndian != BitConverter.IsLittleEndian)
            {
                Array.Reverse(bytes);
            }

            return bytes;
        }
    }
}